home *** CD-ROM | disk | FTP | other *** search
- /*
- File: dcmd.h
-
- Contains: MacsBug debugger command interface.
-
- Version: Technology: MacsBug
- Release: MacsBug 6.6
-
- Copyright: © 1988, 1994-1999, 1999 by Apple Computer, Inc., All Rights Reserved.
-
- Bugs?: For bug reports, consult the following page on
- the World Wide Web:
-
- http://developer.apple.com/bugreporter/
-
- */
- #ifndef __DCMD__
- #define __DCMD__
-
- #ifndef __MACTYPES__
- #include <MacTypes.h>
- #endif
-
- #ifndef __MACHINEEXCEPTIONS__
- #include <MachineExceptions.h>
- #endif
-
-
-
-
- #if PRAGMA_ONCE
- #pragma once
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if PRAGMA_IMPORT
- #pragma import on
- #endif
-
- #if PRAGMA_STRUCT_ALIGN
- #pragma options align=mac68k
- #elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(push, 2)
- #elif PRAGMA_STRUCT_PACK
- #pragma pack(2)
- #endif
-
- /* Possible requests from the debugger to the command*/
- enum {
- dcmdInit = 0, /* Initialize the Dcmd */
- dcmdDoIt = 1, /* Normal Dcmd execution */
- dcmdHelp = 2, /* Display help for Dcmd */
- /* Requests added to MacsBug in 6.5d10 that are only sent to format 3 or newer dcmds. */
- dcmdSecondaryInit = 3, /* Second time to init after all System patches have been loaded */
- dcmdShutdown = 4, /* Dcmd should remove any patches (if possible) */
- dcmdGetInfo = 5 /* Return dcmd version and pointer to help text */
- };
-
-
- /* 68K register file indices into the RegisterFile.*/
- enum {
- D0Register = 0,
- D1Register = 1,
- D2Register = 2,
- D3Register = 3,
- D4Register = 4,
- D5Register = 5,
- D6Register = 6,
- D7Register = 7,
- A0Register = 8,
- A1Register = 9,
- A2Register = 10,
- A3Register = 11,
- A4Register = 12,
- A5Register = 13,
- A6Register = 14,
- A7Register = 15,
- PCRegister = 16,
- SRRegister = 17 /* SR is only 16 bits and is stored in the high word */
- };
-
-
- /* Heap block types*/
- enum {
- freeBlock = 0,
- nonrelocatableBlock = 1,
- relocatableBlock = 2
- };
-
-
- /* The format of the 68K registers passed to the dcmd.*/
- typedef long RegisterFile[18];
- typedef long * RegisterFilePtr;
-
- /* Structure used to pass information to and from the dcmd.*/
-
- struct dcmdBlock {
- RegisterFilePtr registerFile; /* pointer to 68K CPU register set */
- short request; /* what action we are requested to take */
- Boolean aborted; /* Set to true if the user types a key while scrolling */
- Boolean pad1; /* align to word boundary */
- UInt32 macsBugVersion; /* version of MacsBug we are running under */
- UInt16 maxCallback; /* maximum valid callback we can make */
- UInt8 currentISA; /* ISA of current PC */
- UInt8 pad2; /* align to word boundary */
- ExceptionInformationPowerPC * theException; /* Pointer to PowerPC machine state if ISA is PowerPC */
- Ptr requestIOBlock; /* general-purpose input/output data block pointer */
- };
- typedef struct dcmdBlock dcmdBlock;
- typedef dcmdBlock * dcmdBlockPtr;
-
-
- struct GetInfoRequestBlock {
- Str255 usageStr;
- Str255 creditsStr;
- NumVersion dcmdVersion;
- };
- typedef struct GetInfoRequestBlock GetInfoRequestBlock;
- typedef GetInfoRequestBlock * GetInfoRequestBlockPtr;
-
- /*
- These are some useful macros for filling in format 3 version and string fields.
- */
-
- #define dcmdFillVersion(paramPtr, version) \
- * (long *) &((GetInfoRequestBlockPtr) (paramPtr)->requestIOBlock)->dcmdVersion = (version)
-
-
- #define dcmdFillString(paramPtr, which, theStr) \
- BlockMoveData(theStr, &((GetInfoRequestBlockPtr) paramPtr->requestIOBlock)->which, (theStr)[0]+1)
-
-
- /*
- MacsBug callback routines that can be called by the dcmd.
- */
-
- /*
- Draw the text in the Pascal string as one or more lines separated by CR's.
- Each line causes the MacsBug display to be scrolled and the new line to be
- drawn at the bottom. If the user types a key while scrolling then the aborted
- flag is set telling the command to terminate immediately.
- */
- EXTERN_API( void )
- dcmdDrawLine (ConstStr255Param str);
-
-
- /*
- Draw the text in the Pascal string as a continuation of the current line.
- CR's are not given special treatment.
- */
- EXTERN_API( void )
- dcmdDrawString (ConstStr255Param str);
-
-
- /*
- Draw a given number of characters starting from the given pointer as a
- continuation of the current line. CR's are not given special treatment.
- */
- EXTERN_API( void )
- dcmdDrawText (char * text,
- short length);
-
-
- /*
- Scrolls the MacsBug display up one line leaving a blank line at the bottom.
- */
- EXTERN_API( void )
- dcmdScroll (void);
-
-
- /*
- Display the Pascal string in the command line area and wait for a key to be pressed.
- Return TRUE if the user typed Return. All other keys return FALSE. MacsBug saves this
- key and adds it to the command line once the current command completes. Typing any
- key other than Return sets the aborted flag and tells the command to terminate immediately.
- */
- EXTERN_API( Boolean )
- dcmdDrawPrompt (ConstStr255Param str);
-
-
- /*
- Get the current command line position.
- */
- EXTERN_API( short )
- dcmdGetPosition (void);
-
-
- /*
- Set the current command line position. This should only be set to a value returned
- by dcmdGetPosition.
- */
- EXTERN_API( void )
- dcmdSetPosition (short pos);
-
-
- /*
- Return the next character on the command line or CR if the entire line has been scanned
- */
- EXTERN_API( short )
- dcmdGetNextChar (void);
-
-
- /*
- Return the next character on the command line or CR if the entire line has been scanned.
- However, the current command line position is not changed.
- */
- EXTERN_API( short )
- dcmdPeekAtNextChar (void);
-
-
- /*
- Copy all characters from the command line to the parameter string until a delimiter
- is found or the end of the command line is reached. A delimiter is either a space,
- a comma or a CR. Both single and double quoted strings are allowed on the command
- line. However, the leading and trailing quotes must be of the same type. The parameter
- string is returned without the quotes. This function returns the delimiter.
- */
- EXTERN_API( short )
- dcmdGetNextParameter (Str255 str);
-
-
- /*
- Parse the command line for the next expression. All expressions are evaluated to 32 bits.
- This function returns the delimiter after the expression. The possible delimiters are
- space, comma and CR. Space is not treated as a delimiter in the middle of expressions,
- unless it's before a binary '-' (minus). For instance, '1 + 2' will return a value of 3
- and the delimiter will be the char following the 2. '1 - 2' will return a value of 1
- and the delimeter is the space character before the '-'. This is done so that built-in
- commands and dcmds can properly parse '-x' options. The return parameter 'ok' tells if
- the expression was parsed successfully as far as syntax is concerned.
- */
- EXTERN_API( short )
- dcmdGetNextExpression (long * value,
- Boolean * ok);
-
-
- /*
- Copy the break message MacsBug displayed the last time it was entered into str.
- This may contain multiple lines separated by CR's.
- */
- EXTERN_API( void )
- dcmdGetBreakMessage (Str255 str);
-
-
- /*
- Return a symbolic representation for address in str. If no symbol can be found
- then an empty string is returned. The format of the symbol returned is Name+00000.
- */
- EXTERN_API( void )
- dcmdGetNameAndOffset (long address,
- Str255 str);
-
-
- /*
- Return the trap name for the trap number. If no symbol can be found
- then an empty string is returned.
- */
- EXTERN_API( void )
- dcmdGetTrapName (short trapNumber,
- Str255 trapName);
-
-
- /*
- Return a pointer the macro name for the given value. If no macro can be found
- then a nil is returned.
- */
- EXTERN_API( StringPtr )
- dcmdGetMacroName (long value);
-
-
- /*
- When a debugger command is called, the debugger's world (low memory) is installed.
- Commands that want to reference the user's world can swap back and forth between the
- two worlds by making this call. This procedure does nothing in MacsBug; there is no
- distinction between user and debugger worlds. It is included to support other
- debuggers that might want to take advantage of it.
- */
- EXTERN_API( void )
- dcmdSwapWorlds (void);
-
-
- /*
- Toggle between the user and debugger displays. The first call restores the user's actual screen.
- The second call restores the debugger's screen.
- */
- EXTERN_API( void )
- dcmdSwapScreens (void);
-
-
- /*
- Walk through the blocks in the current heap, calling DoThis for each block.
- The blockAddress and blockLength pertain to the data in the heap block, not including
- the block header. The addrOfMasterPtr is the master pointer's location in the heap,
- not the value of the master ptr. The blockType is defined by the constants freeBlock,
- nonrelocatableBlock and relocatableBlock. The booleans locked, purgeable and resource
- reflect the state of the block.
- */
- typedef CALLBACK_API( void , DoThisPtr )(long blockAddress, long blockLength, long addrOfMasterPtr, short blockType, Boolean locked, Boolean purgeable, Boolean resource);
- EXTERN_API( void )
- dcmdForAllHeapBlocks (DoThisPtr DoThis);
-
-
- #if PRAGMA_STRUCT_ALIGN
- #pragma options align=reset
- #elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(pop)
- #elif PRAGMA_STRUCT_PACK
- #pragma pack()
- #endif
-
- #ifdef PRAGMA_IMPORT_OFF
- #pragma import off
- #elif PRAGMA_IMPORT
- #pragma import reset
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* __DCMD__ */
-
-